package LeetcodeTest_ten;
//Dota2 参议院
public class predictPartyVictory
{
    public static void main(String[] args)
    {
        String answer=solution.predictPartyVictory("DDDRRDRRRDDRRRDDDDDR");
        System.out.println(answer);
    }
}
class solution
{
    public static String predictPartyVictory(String senate)
    {
        if(senate.length()==1)
            return senate.charAt(0)=='R'? "Radiant":"Dire";
        int i,j;
        int flag[]=new int[senate.length()];
        i=j=0;
        while (true)
        {
            while(flag[i]!=1)
            {
                j=i+1;
                if(j==senate.length())
                    j=0;
                while (flag[j] == 1)
                {
                    j++;
                    if (j == senate.length())
                        j = 0;
                }
                while (senate.charAt(i) == senate.charAt(j)||flag[j]==1)
                {
                    if (i == j)
                        return senate.charAt(i) == 'R' ? "Radiant" : "Dire";
                    j++;
                    if (j == senate.length())
                        j = 0;
                }
                flag[j] = 1;
                System.out.print(j+"  ");
                i++;
                if (i == senate.length())
                    i = 0;
            }
            i++;
            if (i == senate.length())
                i = 0;
        }
    }
}